package com.ityedao.String案例;

import java.util.Scanner;

public class LoginCase {
    public static void main(String[] args) {
        for (int i = 0; i < 3; i ++) {
            System.out.println("欢迎进入X系统，请输入登录账号和密码~");
            Scanner sc = new Scanner(System.in);
            System.out.println("账号：");
            String name = sc.next();
            System.out.println("密码：");
            String password = sc.next();
            boolean flag = login(name, password);
            if (flag){
                System.out.println("登陆成功~");
                break;
            }else {
                System.out.println("账号或密码错误请重试~");
            }
        }
    }

    /**
     * 登录功能
     * @param name 账号名
     * @param password 密码
     */
    public static boolean login(String name, String password) {
        String okName = "ityedao";
        String okPassword = "123456";

        return okName.equals(name) && okPassword.equals(password);

//        if (okName.equals(name) && okPassword.equals(password)){
//            System.out.println("恭喜登录成功~");
//            return true;
//        }else {
//            return false;
//        }
    }
}
